/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AnalysisPanel.java
 *
 * Created on 2011-9-17, 15:58:52
 */
package com.football.lottery.ui;

import java.awt.CardLayout;

/**
 *
 * @author I am god
 */
public class AnalysisPanel extends javax.swing.JPanel
{
  private final MainFrame mainFrame;
  private OddsAnalysisPanel oddsAnalysisPanel;
  private ForecastAnalysisPanel forecastAnalysisPanel;
  private CardLayout card;
      
  /** Creates new form AnalysisPanel */

  AnalysisPanel(MainFrame mainFrame)
  {
    initComponents();
    this.card = (CardLayout) this.showPanel.getLayout();
    this.mainFrame = mainFrame;
  }

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonPanel = new javax.swing.JPanel();
        RateAnalysisButton = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        showPanel = new javax.swing.JPanel();

        setLayout(new java.awt.BorderLayout());

        RateAnalysisButton.setText(org.openide.util.NbBundle.getMessage(AnalysisPanel.class, "AnalysisPanel.RateAnalysisButton.text")); // NOI18N
        RateAnalysisButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RateAnalysisButtonActionPerformed(evt);
            }
        });

        jButton1.setText(org.openide.util.NbBundle.getMessage(AnalysisPanel.class, "AnalysisPanel.jButton1.text")); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout buttonPanelLayout = new javax.swing.GroupLayout(buttonPanel);
        buttonPanel.setLayout(buttonPanelLayout);
        buttonPanelLayout.setHorizontalGroup(
            buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(buttonPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(RateAnalysisButton)
                    .addComponent(jButton1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        buttonPanelLayout.setVerticalGroup(
            buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(buttonPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(RateAnalysisButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addContainerGap(288, Short.MAX_VALUE))
        );

        add(buttonPanel, java.awt.BorderLayout.LINE_START);

        showPanel.setLayout(new java.awt.CardLayout());
        add(showPanel, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

  private void RateAnalysisButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_RateAnalysisButtonActionPerformed
  {//GEN-HEADEREND:event_RateAnalysisButtonActionPerformed
    new Thread(new Runnable() {
      @Override
      public void run()
      {
        showOddsHitPanel();
      }
    }).start();
  }//GEN-LAST:event_RateAnalysisButtonActionPerformed

  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed
  {//GEN-HEADEREND:event_jButton1ActionPerformed
    new Thread(new Runnable() {
      @Override
      public void run()
      {
        showForecastAnalysisPanel();
      }
    }).start();
  }//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton RateAnalysisButton;
    private javax.swing.JPanel buttonPanel;
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel showPanel;
    // End of variables declaration//GEN-END:variables
    
  private void showOddsHitPanel()
  {
    if (oddsAnalysisPanel == null)
    {
      oddsAnalysisPanel = new OddsAnalysisPanel();
      showPanel.add(oddsAnalysisPanel, "oddsAnalysis");
    }
    this.card.show(showPanel, "oddsAnalysis");
    showPanel.setVisible(false);
    showPanel.setVisible(true);
  }
  
  private void showForecastAnalysisPanel()
  {
    if (forecastAnalysisPanel == null)
    {
      forecastAnalysisPanel = new ForecastAnalysisPanel();
      showPanel.add(forecastAnalysisPanel, "forecastAnalysis");
    }
    this.card.show(showPanel, "forecastAnalysis");
    showPanel.setVisible(false);
    showPanel.setVisible(true);
  }

}
